package com.zzc.another;

import java.io.File;
import java.util.ArrayList;

public class FileAsistant{
	/**
	 * 递归讀取目录下的所有文件及子目录下所有文件
	 * @param path= "C:\\Users\\Administrator\\Desktop\\新数据1";
	 * @return
	 */
	public static void findDir(String path,ArrayList<String> names){
		File dir = new File(path);
		if (dir.isDirectory()) {
			System.out.println("获取"+path+"下的集合");
			String[] children = dir.list();
			// 递归读取目录中的子目录下
			for (int i = 0; i < children.length; i++) {
				String chidPaath = path + '\\' + children[i];
				if (new File(chidPaath).isDirectory()) {
					findDir(chidPaath,names);
				} else {
					//判断是否为markdown文件
					System.out.println(chidPaath);
					if (chidPaath.endsWith(".md")){
						System.out.println("是的");
						names.add(chidPaath);
					}
				}
			}
		}
	}
}
